home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / shopdrop.swf / scripts / __Packages / smashing / SoundHandler.as < prev    next >
Text File  |  2007-09-27  |  2KB  |  95 lines

  1. class smashing.SoundHandler
  2. {
  3.    var cSound = 0;
  4.    var bMute = false;
  5.    function SoundHandler(loc)
  6.    {
  7.       this.location = loc;
  8.       this.aSnd = [];
  9.       var _loc3_ = undefined;
  10.       var _loc2_ = 0;
  11.       while(_loc2_ < 8)
  12.       {
  13.          _loc3_ = loc.createEmptyMovieClip("mcSnd" + _loc2_,_loc2_);
  14.          this.aSnd[_loc2_] = new Sound(_loc3_);
  15.          this.aSnd[_loc2_].bInterrupt = true;
  16.          _loc2_ = _loc2_ + 1;
  17.       }
  18.    }
  19.    function playSnd(sId, vol, oEnd)
  20.    {
  21.       if(this.bMute == true)
  22.       {
  23.          return undefined;
  24.       }
  25.       var _loc2_ = this.aSnd[this.cSound];
  26.       var _loc3_ = 1;
  27.       while(_loc2_.bInterrupt == false)
  28.       {
  29.          if(_loc3_ >= this.aSnd.length)
  30.          {
  31.             return undefined;
  32.          }
  33.          this.cSound = this.cSound + 1;
  34.          if(this.cSound >= this.aSnd.length)
  35.          {
  36.             this.cSound = 0;
  37.          }
  38.          _loc2_ = this.aSnd[this.cSound];
  39.       }
  40.       _loc2_.stop();
  41.       if(oEnd != undefined)
  42.       {
  43.          _loc2_.oEndRecv = oEnd;
  44.          _loc2_.bInterrupt = false;
  45.          _loc2_.onSoundComplete = this.onEnd;
  46.       }
  47.       if(vol != undefined)
  48.       {
  49.          _loc2_.setVolume(vol);
  50.       }
  51.       else
  52.       {
  53.          _loc2_.setVolume(100);
  54.       }
  55.       _loc2_.attachSound(sId);
  56.       _loc2_.start();
  57.       this.cSound = this.cSound + 1;
  58.       if(this.cSound >= this.aSnd.length)
  59.       {
  60.          this.cSound = 0;
  61.       }
  62.       return _loc2_;
  63.    }
  64.    function onEnd()
  65.    {
  66.       this.bInterrupt = true;
  67.       this.oEndRecv.onSoundEnd();
  68.       delete this.oEndRecv;
  69.       delete this.onSoundComplete;
  70.    }
  71.    function stopSounds()
  72.    {
  73.       stopAllSounds();
  74.       var _loc3_ = undefined;
  75.       var _loc2_ = 0;
  76.       while(_loc2_ < this.aSnd.length)
  77.       {
  78.          _loc3_ = this.aSnd[_loc2_];
  79.          _loc3_.bInterrupt = true;
  80.          delete _loc3_.oEndRecv;
  81.          delete _loc3_.onSoundComplete;
  82.          _loc2_ = _loc2_ + 1;
  83.       }
  84.    }
  85.    function mute()
  86.    {
  87.       this.stopSounds();
  88.       this.bMute = true;
  89.    }
  90.    function unMute()
  91.    {
  92.       this.bMute = false;
  93.    }
  94. }
  95.